package com.yilin.medical.activity;

import java.util.Arrays;
import java.util.List;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

import com.yilin.medical.R;

public class WanShanXinXiActivity extends BaseActivity implements
		OnItemSelectedListener {
	private Context context;
	private Spinner mSpinnerXingBie, mSpinnerXueli, mSpinnerKeShi,
			mSpinnerzhiwu, mSpinnerzhicheng, mSpinnerzhiye, mSpinnerProvince,
			mSpinnercity, mSpinnercounty, mSpinnerhospital,
			mSpinnerhospitaldengji;
	private List<String> genderlist;
	private List<String> xuelilist;
	private List<String> zhiwulist;
	private List<String> keshilist;
	private List<String> zhichenglist;
	private List<String> zhiyelist;
	private List<String> provincelist;
	private List<String> citylist;
	private List<String> countylist;
	private List<String> hospitallist ;
	private List<String> hospitaldengjiist ;
	private ArrayAdapter<String> Gnderadapter;
	private ArrayAdapter<String> xueliadapter;
	private ArrayAdapter<String> zhiwuadapter;
	private ArrayAdapter<String> keshiadapter;
	private ArrayAdapter<String> zhichengdapter;
	private ArrayAdapter<String> zhiyeadapter,provinceadapter,cityadapter,countyadapter,hospitaladapter,hospitaldengjiadapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentViewWithTitle(R.layout.activity_wanshanxinxi);
		context = this;
		initView();

		context = this;
		initView();
		genderlist = Arrays.asList(this.getResources().getStringArray(
				R.array.gender));
		xuelilist = Arrays.asList(this.getResources().getStringArray(
				R.array.xueli));
		zhiwulist = Arrays.asList(this.getResources().getStringArray(
				R.array.zhiwu));
		zhichenglist = Arrays.asList(this.getResources().getStringArray(
				R.array.zhicheng));
		zhiyelist = Arrays.asList(getResources().getStringArray(R.array.zhiye));
		provincelist = Arrays.asList(getResources().getStringArray(
				R.array.province));
		keshilist = Arrays.asList(getResources()
				.getStringArray(R.array.branch));
		
		 
		 zhichenglist = Arrays.asList(this.getResources().getStringArray(
					R.array.gender));
		 zhiyelist = Arrays.asList(this.getResources().getStringArray(
					R.array.xueli));
		 provincelist = Arrays.asList(this.getResources().getStringArray(
					R.array.zhiwu));
		 citylist = Arrays.asList(this.getResources().getStringArray(
					R.array.zhicheng));
		 countylist = Arrays.asList(getResources().getStringArray(R.array.zhiye));
			provincelist = Arrays.asList(getResources().getStringArray(
					R.array.province));
			hospitallist = Arrays.asList(getResources()
					.getStringArray(R.array.branch));
			hospitaldengjiist = Arrays.asList(getResources()
					.getStringArray(R.array.branch));
			
			zhichenglist = Arrays.asList(getResources()
					.getStringArray(R.array.branch));
		
		registerListenner();
		initAdapter();

	}

	private void initAdapter() {
		Gnderadapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, genderlist);
		Gnderadapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mSpinnerXingBie.setAdapter(Gnderadapter);

		xueliadapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, xuelilist);
		xueliadapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mSpinnerXueli.setAdapter(xueliadapter);

		zhiwuadapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, zhiwulist);
		zhiwuadapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mSpinnerzhiwu.setAdapter(zhiwuadapter);

		keshiadapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, keshilist);
		keshiadapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mSpinnerKeShi.setAdapter(keshiadapter);
		//zhiyeadapter,provinceadapter,cityadapter,countyadapter,hospitaladapter,hospitaldengjiadapter;
		
		zhiyeadapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, zhiyelist);
		zhiyeadapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mSpinnerzhiye.setAdapter(zhiyeadapter);
		
		
		provinceadapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, provincelist);
		provinceadapter
		.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mSpinnerProvince.setAdapter(provinceadapter);
		
		cityadapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item,citylist);
		cityadapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mSpinnercity.setAdapter(cityadapter);
		
		countyadapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item,countylist);
		countyadapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mSpinnercounty.setAdapter(countyadapter);
		
		hospitaladapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item,hospitallist);
		hospitaladapter
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mSpinnerhospital.setAdapter(hospitaladapter);
		
		
		
		hospitaldengjiadapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item,hospitaldengjiist);
		hospitaldengjiadapter
		.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mSpinnerhospitaldengji.setAdapter(hospitaldengjiadapter);
		
		
		zhichengdapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item,zhichenglist);
		zhichengdapter
		.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		mSpinnerzhicheng.setAdapter(zhichengdapter);
	}

	private void registerListenner() {
		/*Spinner mSpinnerXingBie, mSpinnerXueli, mSpinnerKeShi,
		mSpinnerzhiwu, mSpinnerzhicheng, mSpinnerzhiye, mSpinnerProvince,
		mSpinnercity, mSpinnercounty, mSpinnerhospital,
		mSpinnerhospitaldengji;*/
		mSpinnerXingBie
				.setOnItemSelectedListener(this);
		mSpinnerXueli
		.setOnItemSelectedListener(this);
		mSpinnerzhiwu
				.setOnItemSelectedListener(this);
		mSpinnerKeShi
				.setOnItemSelectedListener(this);
		
		mSpinnerzhicheng
		.setOnItemSelectedListener(this);
		mSpinnerzhiye
		.setOnItemSelectedListener(this);
		mSpinnerProvince
		.setOnItemSelectedListener(this);
		mSpinnercity
		.setOnItemSelectedListener(this);
		mSpinnercounty
		.setOnItemSelectedListener(this);
		mSpinnerhospital
		.setOnItemSelectedListener(this);
		mSpinnerhospitaldengji
		.setOnItemSelectedListener(this);

	}

	private void initView() {
		mTitle.getTitle().setText("完善信息");
		mSpinnerXingBie = (Spinner) findViewById(R.id.spinner_xingbie);
		mSpinnerXueli = (Spinner) findViewById(R.id.spinner_xueli);
		mSpinnerzhiwu = (Spinner) findViewById(R.id.spinner_zhiwu);
		mSpinnerKeShi = (Spinner) findViewById(R.id.spinner_keshi);
		mSpinnerzhicheng = (Spinner) findViewById(R.id.spinner_zhicheng);
		mSpinnerzhiye = (Spinner) findViewById(R.id.spinner_zhiye);
		mSpinnerProvince = (Spinner) findViewById(R.id.spinner_sheng);
		mSpinnercity = (Spinner) findViewById(R.id.spinner_shi);
		mSpinnercounty = (Spinner) findViewById(R.id.spinner_xian);
		mSpinnerhospital = (Spinner) findViewById(R.id.spinner_yiyuan);
		mSpinnerhospitaldengji = (Spinner) findViewById(R.id.spinner_yiyuandengji);

	}

	@Override
	public void onClick(View v) {
		super.onClick(v);
		switch (v.getId()) {
		}

	}

	/**
	 * spinner的方法
	 */
	@Override
	public void onItemSelected(AdapterView<?> parent, View view, int position,
			long id) {
		view.setVisibility(View.VISIBLE);
	}

	/**
	 * spinner的方法
	 */
	@Override
	public void onNothingSelected(AdapterView<?> parent) {
		parent.setVisibility(View.VISIBLE);
	}

}
